<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
         <style>
            .barsearch {
                height:14px;
                width:100px;
            }
            .barsearchbutton {
                border-width:1px;
                background-color:#{a4jSkin.generalBackgroundColor};
            }
        </style>    

       <a4j:form id="listForm">
        <rich:toolBar height="34" width="700" itemSeparator="line">
            <rich:toolBarGroup>
                <a4j:commandLink reRender="rightPanel" action="#{RightsAgent.showNewProfilePanel}">
                    <h:graphicImage id="new" value="/richfaces/toolBar/images/print_edit.gif" border="0"/>
                    <h:outputLabel value="Nowy" for="new" />
                </a4j:commandLink>
            </rich:toolBarGroup>
            <rich:toolBarGroup>
                <a4j:commandLink reRender="rightList, messages" action="#{RightsAgent.save}">
                    <h:graphicImage id="edit" value="/richfaces/toolBar/images/print.gif" />
                    <h:outputLabel value="Zapisz" for="edit" />
                </a4j:commandLink>
            </rich:toolBarGroup>
            <rich:toolBarGroup>
                <a4j:commandLink reRender="listForm, messages" action="#{RightsAgent.refresh}">
                    <h:graphicImage id="refresh" value="/richfaces/toolBar/images/print_preview.gif" />
                    <h:outputLabel value="Odśwież" for="refresh" />
                </a4j:commandLink>
            </rich:toolBarGroup>
            <rich:toolBarGroup location="right">
                <h:selectOneMenu value="#{RightsAgent.selectedProfileId}" >
                    <a4j:support event="onchange" reRender="rightList, messages" action="#{RightsAgent.selectProfile}"/>
                    <f:selectItems value="#{RightsAgent.profilesList}"/>
                </h:selectOneMenu>
            </rich:toolBarGroup>
        </rich:toolBar>
        <h:panelGroup id="rightPanel">
            <h:panelGrid width="500" columns="1" rendered="#{RightsAgent.showNewProfile}">
                <h:inputText value="#{RightsAgent.profileName}"/>
                <h:panelGrid columns="2">
                    <a4j:commandButton value="Dodaj" action="#{RightsAgent.createProfile}" reRender="listForm, messages"/>
                    <a4j:commandButton value="Anuluj" type="reset" immediate="yes" action="#{RightsAgent.hideNewProfilePanel}" reRender="rightPanel"/>
                </h:panelGrid>
            </h:panelGrid>
        </h:panelGroup>
            <h:panelGroup id="rightList">
                <rich:dataTable value="#{RightsAgent.groups}" var="groupRow" rowKeyVar="group" border="1" width="700" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" onRowMouseOver="this.style.backgroundColor='#6c6'">
                    <f:facet name="header">
                        <rich:columnGroup>
                            <rich:column width="20">
                                <h:outputText value="Wybór"/>
                            </rich:column>
                            <rich:column>
                                <h:outputText value="Uprawnienia"/>
                            </rich:column>
                        </rich:columnGroup>
                    </f:facet>
                    <rich:column colspan="2">
                        <h:outputText value="#{groupRow.grpName}"/>
                    </rich:column>
                    <rich:subTable id="sub" var="rightRow" rowKeyVar="right" value="#{groupRow.rights}">
                        <rich:column>
                            <h:selectBooleanCheckbox value="#{rightRow.selected}"/>
                        </rich:column>
                        <rich:column>
                            <h:outputText value="#{rightRow.rghName}"/>
                        </rich:column>
                    </rich:subTable>
                </rich:dataTable>
            </h:panelGroup>
        </a4j:form>
</ui:composition>
